//
//  MOrder.m
//  RRQS
//
//  Created by kyjun on 16/3/24.
//
//

#import "MOrder.h"


@implementation MOrder

+ (NSDictionary *)mj_objectClassInArray{
    return @{
             
             @"goods_info" : @"MOrder"
             };//前边，是属性数组的名字，后边就是类名
}

-(instancetype)initWithItem:(NSDictionary *)item{
    self = [super init];
    if(self){
        _rowID = [item objectForKey:@"mainid"];
        _address = [item objectForKey:@"sendaddress"];
        _totalMoney = [item objectForKey:@"total"];
        _shipFee = [item objectForKey:@"returnpay"];
        _createDate = [item objectForKey:@"creat_time"];
        _addTime = [item objectForKey: @"add_time"];
        _addressRoad = [item objectForKey: @"address_road"];
        NSArray* array = [item objectForKey:@"items"];
        if(array){
            [array enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                MSubOrder* sub = [[MSubOrder alloc]initWithItem:obj];
                [self.arraySubOrder addObject:sub];
            }];
        }
    }
    return self;
}

-(instancetype)initWithOrder:(NSDictionary *)item{
    self = [super init];
    if(self){
        _rowID = [item objectForKey:@"main_id"];
        _address = [item objectForKey:@"sendaddress"];
        _totalMoney = [item objectForKey:@"total"];
        _shipFee = [item objectForKey:@"returnpay"];
        _createDate = [item objectForKey:@"creat_time"];
        _addTime = [item objectForKey: @"add_time"];
        _getTime = [item objectForKey:@"get_time"];
        _sendTime = [item objectForKey:@"send_time"];
        _empID = [item objectForKey:@"emp_id"];
        _addressRoad = [item objectForKey: @"address_road"];
        NSArray* array = [item objectForKey:@"items"];
        if(![WMHelper isNULLOrnil:array]){
            [array enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                MSubOrder* sub = [[MSubOrder alloc]initWithOrder:obj];
                [self.arraySubOrder addObject:sub];
            }];
        }
    }
    return self;
}

-(instancetype)initWithStore:(NSDictionary *)item{
    self = [super init];
    if(self){
        _rowID = [item objectForKey:@"main_id"];
        _address = [item objectForKey:@"sendaddress"];
        _totalMoney = [item objectForKey:@"total"];
        _shipFee = [item objectForKey:@"returnpay"];
        _createDate = [item objectForKey:@"creat_time"];
        _addTime = [item objectForKey:@"add_time"];
        _getTime = [item objectForKey:@"get_time"];
        _sendTime = [item objectForKey:@"send_time"];
        _spendTime = [item objectForKey:@"times"];
        _empID = [item objectForKey:@"emp_id"];
        _orderMark = [item objectForKey:@"order_mark"];
        _addressRoad = [item objectForKey: @"address_road"];
        NSArray* array = [item objectForKey:@"items"];
        if(![WMHelper isNULLOrnil:array]){
            [array enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                MStore* sub = [[MStore alloc]initWithItem:obj];
                [self.arrayStore addObject:sub];
            }];
        }
    }
    return self;
    
}

-(instancetype)initWithFished:(NSDictionary *)item{
    self = [super init];
    if(self){
        _rowID = [item objectForKey:@"main_id"];
        _address = [item objectForKey:@"sendaddress"];
        _totalMoney = [item objectForKey:@"total"];
        _shipFee = [item objectForKey:@"returnpay"];
        _createDate = [item objectForKey:@"creat_time"];
        _addTime = [item objectForKey:@"add_time"];
        _getTime = [item objectForKey:@"get_time"];
        _sendTime = [item objectForKey:@"send_time"];
        _addressRoad = [item objectForKey: @"address_road"];
        NSString* arrayStr = [item objectForKey:@"items"];
        if(arrayStr){
            _arrayStore = [[NSMutableArray alloc]initWithArray:[arrayStr componentsSeparatedByString:@","]];
        }
    }
    return self;
    
}


-(NSMutableArray *)arraySubOrder{
    if(!_arraySubOrder){
        _arraySubOrder = [[NSMutableArray alloc]init];
    }
    return _arraySubOrder;
}

-(NSMutableArray *)arrayStore{
    if(!_arrayStore){
        _arrayStore = [[NSMutableArray alloc]init];
    }
    return _arrayStore;
}

-(NSArray *)arrayGoodsName{
    if(!_arrayGoodsName){
        _arrayGoodsName  = [[NSArray alloc]init];
    }
    return _arrayGoodsName;
}
@end
